#pragma once

#include <iostream>
#include <vector>
#include <ctime>

typedef void (*task_t)();

void PrintLog()
{
    std::cout << "打印日志" << std::endl;
}

void Download()
{
    std::cout << "下载任务" << std::endl;
}

void Upload()
{
    std::cout << "上传任务" << std::endl;
}

class TaskManager
{
public:
    TaskManager()
    {
        srand(time(nullptr));
    }

    //注册任务
    void Register(task_t t)
    {
        _tasks.push_back(t);
    }

    //随机返回一个任务码
    int Code()
    {
        return rand() % _tasks.size();
    }

    //执行任务
    void Execute(int code)
    {
        _tasks[code]();
    }
private:
    std::vector<task_t> _tasks;
};